<template>
  <div>
      <ul>
          <li><router-link to="/contact/allcontacts">All Contacts</router-link> </li>
          <li><router-link to="/contact/alice">Alice</router-link></li>
          <li><router-link to="/contact/bob">Bob</router-link></li>
      </ul>
      <button @click="Btnfn">随机显示</button>
      <router-view></router-view>
  </div>
</template>

<script>
export default {
  methods: {
    Btnfn() {
     const  arr = ['/contact/allContacts', '/contact/alice', '/contact/bob']
      // 生成随机数
      const a = Math.floor(Math.random() * arr.length)
      // 传参
      this.$router.push(`${arr[a]}`)
    },
  },
}

</script>

<style>

</style>